    <?php  include VIEWPATH.'common/head.php';  ?>
    <link href="<?php echo FONT_PATH.'static/bootstrap';?>/css/plugins/chosen/chosen.css?v=1" rel="stylesheet">
    <style>
        ul.chosen-results li{text-align:left !important;}
    </style>
    <body class="gray-bg">
    <div class="add-btn" style="float:right;margin-bottom:5px;">
        <div class="modal fade" id="img_list" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog" style="width: 90%;"><div class="modal-content"></div></div>
        </div>
    </div>
    <div class="add-btn" style="float:right;margin-bottom:5px;">
        <div class="modal fade" id="add_img" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog" style="width: 60%;"><div class="modal-content"></div></div>
        </div>
    </div>
    <div class="clearfix"></div>
    <div class="wrapper wrapper-content ">
        <div id="topic_list_json" style="display: none"><?php echo $topic_list_json;?></div>
        <div id="tag_list_json" style="display: none"><?php echo $tag_list_json;?></div>
        <script>
            //检测是否在数组中
            function js_in_array(id,id_arr) {
                for(var i=0;i<id_arr.length;i++){
                    if(id === id_arr[i]){
                        // alert(id);
                        // alert(id_arr[i]);
                        return true;
                    }
                }
                return false;
            }
            //生成话题下拉菜单
            function top_list_echo(id,id_arr) {
                var topic_arr = id_arr.split(',');
                var topic_list_json = JSON.parse($('#topic_list_json').text());
                var html = '<select name="topic_list[]" data-id="' + id + '" data-placeholder="选择话题" class="chosen-select topic_list"  multiple  tabindex="1">';
                $.each(topic_list_json, function (n, data) {
                        var selected = (js_in_array(data['id'], topic_arr) ? 'selected' : '');
                        html += '<option ' + selected + '  hassubinfo="true"  value="' + data['id'] + '">' + data['title'] + '</option>';
                    }
                );
                html += '</select>';
                $("#" + id + "").html(html);
                for (var selector in config) $(selector).chosen(config[selector]);
                $('.chosen-container').css('width', "100%");
            }
            //生成标签下拉菜单
            function tag_list_echo(id,id_arr,num) {
                $("#" + id + "").html('');

                id_arr=$("#" + id + "").attr('data-ids');
                var tag_arr = id_arr.split(',');
                var tag_list_json = JSON.parse($('#tag_list_json').text());
                var html = '<select name="tag_list[]" data-id="' + id + '"  data-placeholder="选择标签" class="chosen-select tag_list"  multiple  tabindex="1">';
                $.each(tag_list_json, function (n, data) {
                        var selected = (js_in_array(data['id'], tag_arr) ? 'selected' : '');
                        html += '<option ' + selected + '  hassubinfo="true"  value="' + data['id'] + '">' + data['title'] + '</option>';
                    }
                );
                html += '</select>';
                $("#" + id + "").html(html);
                for (var selector in config) $(selector).chosen(config[selector]);
                $('.chosen-container').css('width', "100%");
            }


            function add_scrolltop(id,rows) {
                // alert(1);
                $("#"+id+"").scrollTop(10);//控制滚动条下移10px
                if( $("#"+id+"").scrollTop()>0 ){
                    var new_rows=rows+1;
                    $("#"+id+"").attr('rows',new_rows);
                    // add_scrolltop(id,new_rows);
                }
                $("#"+id+"").scrollTop(0);//滚动条返回顶部

            }
        </script>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5><?php echo $pageTitle;?></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div>
                            <!-- Nav tabs -->
                            <ul class="nav nav-tabs" role="tablist">

                                <li <?php echo $status_s == 1 ?"class='active'":""?>>
                                    <a href="index.php?c=post&m=index&status=1">待审核</a>
                                </li>

                                <li <?php echo $status_s == '2' ?"class='active'":""?>>
                                    <a href="index.php?c=post&m=index&status=2">已审核</a>
                                </li>
                                <li <?php echo $status_s === 'all' ?"class='active'":""?>>
                                    <a href="index.php?c=post&m=index&status=all">全部</a>
                                </li>

                            </ul>
                        </div>
                        <div>
                            <!-- Tab panes -->
                            <style>
                                <!--
                                .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th{vertical-align:top;}
                                -->
                            </style>
                            <div class="tab-content">
                                <div role="tabpanel" class="tab-pane active" id="sellTab1">
                                    <style type="text/css">
                                        .tg  {border-collapse:collapse;border-spacing:0;}
                                        .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;word-break:normal;border-color:black;}
                                        .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;word-break:normal;border-color:black;}
                                        .tg .tg-us36{vertical-align:middle}
                                    </style>

                                        <?php
                                        $sex = array(0 => "默认", 1 => "男", 2=>"女");
                                        if(!empty($list)){
                                        foreach($list as $data){
                                        ?>
                                            <table class="tg table table-bordered">
                                                <tr style="background: #c8c8c8;">
                                                    <th class="tg-us36" colspan="2" width="10%">
                                                        id:<?php echo $data['id']?>
                                                        <input type="hidden" value="<?php echo $data['id'];?>" class="post_id">
                                                    </th>
                                                    <th class="tg-us36" colspan="2">
                                                        <textarea  rows="1" class="form-control update_title" id="desc_<?php echo $data['id']?>" data-id="<?php echo $data['id']?>" data-title="<?php echo $data['title']?>"><?php echo $data['title']?></textarea>
                                                        <script>
                                                            add_scrolltop('desc_<?php echo $data['id']?>',1);
                                                        </script>


                                                        <!--                                                        <a href="index.php?c=comment&m=index&post_id=--><?php //echo $data['id']?><!--" target="_blank">标题:--><?php //echo $data['title']?><!--</a>-->
                                                    </th>
                                                    <th class="tg-us36">
                                                        封面图片
                                                    </th>
                                                    <th class="tg-us36">
                                                        审核
                                                    </th>
                                                </tr>
                                                <tr>
                                                    <td class="tg-us36" width="8%">
                                                        <a  class="J_menuItem" data-names="用户详情"  href="index.php?c=user&m=user_info&&uid=<?php echo $data['uid'];?>&op=user_info" target="_blank">
                                                            <img src="<?php echo $data['author']['path']?>" onerror='this.src="<?php echo FONT_UPLOAD_PATH.'/static/images.jpg'?>"' width="50">
                                                        </a>
                                                    </td>
                                                    <td class="tg-us36"  width="10%">
                                                        <a  class="J_menuItem" data-names="用户详情"  href="index.php?c=user&m=user_info&&uid=<?php echo $data['uid'];?>&op=user_info" id="u_nickname_<?php echo $data['uid'];?>" target="_blank">
                                                            <?php echo $data['author']['nickname'];?>
                                                        </a>
                                                        <p>
                                                            <span id="u_sex_<?php echo $data['uid'];?>"><?php echo "性别：".$sex[$data['author']['sex']];?></span>
                                                            <a href="index.php?c=user&m=user_edit&uid=<?php echo $data['author']['uid'];?>" data-toggle="modal" data-target="#img_list">编辑</a>
                                                        </p>
                                                    </td>
                                                    <td class="tg-us36" rowspan="3" width="50%">
                                                        <div style="height: 100%;width: 100%;overflow: auto;height: 140px;word-wrap:break-word;word-break:break-all;">
                                                            翻译：<?php echo $data['desc'];?>
                                                        </div>
                                                    </td>
                                                    <td class="tg-us36" rowspan="2" width="8%">
                                                        <div style="height: 100%;width: 100%;">
                                                            评论数：<a  class="J_menuItem" data-names="评论管理"  href="index.php?c=comment&m=index&&post_id=<?php echo $data['id']?>" target="_blank"><?php echo $data['comment_num']?></a><br>
                                                            点赞数：<?php echo $data['like_num']?><br>
                                                            分享数：<?php echo $data['share_num']?><br>
                                                            pv数：<?php echo $data['pv_num']?><br>
                                                            爆光量：<?php echo $data['show_num']?><br>
                                                        </div>
                                                    </td>
                                                    <td class="tg-us36" rowspan="5" width="6%">
                                                        <?php
                                                        $is_img=$data['post_img']['path']?$data['post_img']['path']."?x-oss-process=style/scale-cade2":"";?>
                                                        <button type="button" class="close_s" id="close_<?php echo $data['id']?>" aria-label="Close" style="opacity:0.99;background: #ffffff;color: red;<?php echo !empty($is_img)?'display:block;':'display:none;';?> border: 0px; float:right;" data-imgid="" onclick="del_img(<?php echo $data['id']?>)"><span aria-hidden="true">&times;</span></button>
                                                        <a class="btn " title="<?php echo '宽：'.$data['post_img']['w'].'px,高：'.$data['post_img']['h'].'px,大小：'.intval(intval($data['post_img']['size'])/1024).'kb';?>" href="index.php?c=imgList&m=img_list&id=<?php echo $data['id'];?>" data-toggle="modal" data-target="#img_list" style="background: #ffffff; margin: 0px;">

                                                            <img id="img_<?php echo $data['id'];?>" src="<?php echo $data['post_img']['path']?$data['post_img']['path']."?x-oss-process=style/scale-cade2":""?>" width="100" border="0" onerror='this.src="<?php echo FONT_UPLOAD_PATH.'/static/images.jpg'?>"'  >
                                                        </a>

                                                        <a class="btn btn-danger" href="index.php?c=imgLib&m=add_img&id=<?php echo $data['id'];?>" data-toggle="modal" data-target="#add_img">
                                                            添加
                                                        </a>
                                                    <td class="tg-us36" rowspan="5" width="6%">


                                                        <div  id="is_show_<?php echo $data['id']?>" style="<?php if($data['status'] == 3){ echo ' display:block;';}else{ echo ' display:none;';}?>">
                                                            <a href="index.php?c=post&m=post_check&id=<?php echo $data['id'];?>&type=3" data-toggle="modal" data-target="#img_list" style="line-height: 30px;text-align: center;">恢复</a><br>
                                                        </div>
                                                        <div id="is_check_<?php echo $data['id']?>" style="<?php if($data['status'] != 3){ echo ' display:block;';}else{ echo ' display:none;';}?>">

                                                            <input type="submit" class="submit_up" value="审核通过"><br>
                                                            <a href="index.php?c=post&m=post_check&id=<?php echo $data['id'];?>&type=1" data-toggle="modal" data-target="#img_list" style="line-height: 30px;text-align: center">审核不通过</a><br>
                                                            <a href="index.php?c=post&m=post_check&id=<?php echo $data['id'];?>&type=2" data-toggle="modal" data-target="#img_list" style="line-height: 30px;text-align: center">删除</a>


                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="tg-us36">注册日期</td>
                                                    <td class="tg-us36" id="u_regdate_<?php echo $data['uid'];?>"><?php echo date("Y-m-d H:i:s",$data['author']['regdate']);?></td>
                                                </tr>
                                                <tr>
                                                    <td class="tg-us36">类型</td>
                                                    <td class="tg-us36">
                                                        <?php
                                                        if($data['author']['user_type']==1){echo "注册";}
                                                        if($data['author']['user_type']==2){echo "机器人";}
                                                        if($data['author']['user_type']==3){echo $data['author']['user_source']?$data['author']['user_source'].'导入':"未知导入";}
                                                        ?>
                                                    </td>
                                                    <td class="tg-us36"rowspan="1">
                                                        <a  class="J_menuItem" data-names="操作记录"  href="index.php?c=user&m=admin_log&&post_id=<?php echo $data['id'];?>&s_type=1" target="_blank">管理操作记录</a>
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td class="tg-us36" colspan="2" rowspan="2">
                                                        主帖：<a  class="J_menuItem" data-names="用户详情"  href="index.php?c=user&m=user_info&&uid=<?php echo $data['uid'];?>&op=post" target="_blank"><?php echo $data['author']['pub_num'];?></a>
                                                        评论：<a class="J_menuItem" data-names="用户详情"  href="index.php?c=user&m=user_info&&uid=<?php echo $data['uid'];?>&op=reply" target="_blank"><?php echo $data['author']['reply_num'];?></a><br>
                                                        积分/金币：<?php echo $data['author']['gold_num'];?>
                                                        经验：<?php echo $data['author']['experience'];?>
                                                        信誉：<?php echo $data['author']['reputation'];?>
                                                    </td>
                                                    <td class="tg-us36" colspan="2">
                                                        <div style="float: left;">
                                                            发布时间：<?php echo date('Y-m-d H:i:s',$data['add_time'])?>
                                                        </div>
                                                        <div style="float: right;">
                                                            <?php echo $data['user']['nickname']?'操作人：'.$data['user']['nickname']:""?>
                                                            <?php echo $data['user']['openation_time']?'操作时间:'.date("Y-m-d H:i:s",$data['user']['openation_time']):""?>
                                                            <span class="status_<?php echo $data['id']?>" title="<?php echo $data['user']['desc']?>" style="color: #0d8ddb;">
                                                                <?php
                                                                echo $data['is_audit']==1?"已审核":($data['is_audit'] == 2?"审核中":"待审核");
                                                                echo "(".($data['status']==1?"成功":($data['status'] == 2?"未通过":"已删除")).")";
                                                                ?>
                                                            </span>
                                                        </div>

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="tg-us36" colspan="2">
                                                        <?php echo $this->PostTopicModel->get_topic($data['title'].','.$data['desc'],$new_topic,$new_tag);?>

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="tg-us36">标签</td>
                                                    <td colspan="3" width="72%" class="tg-us36 tag_list_js"
                                                        data-ids="<?php echo !empty($data['tag_data']['ids']) ? implode(',', $data['tag_data']['ids']) : ''?>"
                                                        data-id="<?php echo $data['id']?>"
                                                        id="tag_list_echo_<?php echo $data['id']?>" >
                                                    </td>
                                                    <td colspan="2" class="tg-us36" >
                                                        加精：<label><input type="radio" name="is_hot_<?php echo $data['id'];?>" class="is_hot" value="0" <?php echo $data['is_hot'] == 0 ?'checked="checked"':''?>>普通</label>
                                                        <label style="margin-left: 10px;"><input type="radio" name="is_hot_<?php echo $data['id'];?>" class="is_hot" value="1"  <?php echo $data['is_hot'] == 1 ?'checked="checked"':''?>>加精</label>
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td width="8%" class="tg-us36" >话题</td>
                                                    <td colspan="3" class="tg-us36 topic_list_js"
                                                        data-ids="<?php echo !empty($data['topic_data']['ids']) ? implode(',', $data['topic_data']['ids']) : ''?>"
                                                        width="72%"  id="top_list_echo_<?php echo $data['id']?>" >
                                                    </td>
                                                    <td colspan="2" class="tg-us36"  width="20%">
                                                        分类:<span class="class_text"><?php echo $data['topic_data']['class']?></span>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="tg-us36" colspan="6">
                                                        <audio controls="controls"  preload="load" style="width:100%">
                                                            <source src="<?php echo $data['audio_address']?>" type="audio/mpeg">
                                                            <embed src="<?php echo $data['audio_address']?>" width="500px" height="100px" autostart="false" loop="false">
                                                        </audio>
                                                    </td>
                                                </tr>
                                            </table>
                                        <?php }}else{?>
                                    <div style="text-align: center;color: #ff6600;line-height: 45px;font-size: 15px">太棒了，你已经把未审核的帖子全部审核完了…………</div>
                                    <?php }?>
                                    <div style="text-align: center;color: #ff6600;line-height: 45px;font-size: 15px"><a href="index.php?c=post&m=index&status=1">刷一刷</a></div>
                                    <div class="set_page">
                                        <?php
                                            if($status_s!=1){
                                                echo $multipage;
                                            }
                                        ?>
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="<?php echo FONT_PATH.'static/bootstrap';?>/js/plugins/chosen/chosen.jquery.js?v=1"></script>
    <script src="<?php echo FONT_PATH.'static/bootstrap';?>/js/demo/form-advanced-demo.min.js"></script>
    <script type="text/javascript">
        function del_img(post_id) {
            $.ajax({
                type:'post',
                url:"index.php?c=imgLib&m=del_img",
                data:{'post_id':post_id},
                dataType:'json',
                success:function(result){
                    if(result['status'] == 1){
                        alert("图片删除成功");
                        $('#img_'+post_id+'').attr('src','');
                        $('#close_'+post_id+'').hide();
                    }else{
                        alert("删除图片失败")
                    }
                }
            });
        }
        $(function () {
            //提交审核通过
            $(".submit_up").click(function () {
                var topic_list=$(this).parent().parent().parent().parent().find('.topic_list').val();
                var tag_list=$(this).parent().parent().parent().parent().find('.tag_list').val();
                var is_hot=$(this).parent().parent().parent().parent().find('input[class="is_hot"]:checked').val();
                var post_id=$(this).parent().parent().parent().parent().find('.post_id').val();
                var status=$(this).parent().parent().parent().parent().find('.status');
                var class_text=$(this).parent().parent().parent().parent().find('.class_text');
                $.ajax({
                    type:'post',
                    url:"index.php?c=post&m=update_post",
                    data:{'topic':topic_list,'tag':tag_list,'is_hot':is_hot,'id':post_id},
                    dataType:'json',
                    success:function(result){
                        if(result['status'] == 2){
                            alert(result['msg'])
                        }else{
                            alert("更新成功");
                            // tag
                            $('#tag_list_echo_'+post_id+'').attr('data-ids',result['tag_ids']);
                            // topic
                            $('#top_list_echo_'+post_id+'').attr('data-ids',result['top_ids']);
                            class_text.text(result['class_title']);
                            $('.status_'+post_id+'').text(result['msg']);
                            $('.status_'+post_id+'').css({'color':'red'});
                        }
                    }
                });
            })
            $(document).on("click",".no-results",function() {
                var select_name=$(this).attr('data-name');
                var select_id=$(this).attr('data-id');
                var title=$(this).attr('data-tag');
                $.ajax({
                    type:'post',
                    url:"index.php?c=post&m=add_tag",
                    data:{'title':title,'select_name':select_name},
                    dataType:'json',
                    async:false,
                    success:function(result){
                        if(result['status'] == 2){
                            alert(result['msg'])
                        }else{
                            if(result['type']== 'top'){
                                var ids=$('#'+select_id+'').attr('data-ids');
                                $('#topic_list_json').text(result['json_arr']);
                                $('#'+select_id+'').attr('data-ids',ids+","+result['id']);
                                alert('话题添加成功')
                            }else{
                                var ids=$('#'+select_id+'').attr('data-ids');
                                $('#tag_list_json').text(result['json_arr']);
                                $('#'+select_id+'').attr('data-ids',ids+","+result['id']);
                                alert('标签添加成功')
                            }
                        }
                    }
                });
                if(select_name == 'tag_list[]'){
                    for_tag();
                }else{
                    for_topic();
                }

            });
        })
    </script>
    <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script>

    <script id="upload-tpl" type="text/html">
        <li>
            <img src="<?php echo IMG_HTTP_PATH;?>{{name}}" class="img-thumbnail" width="160px" height="90px" />
            <input type="hidden" name="path[]" value={{name}} />
            <button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        </li>
    </script>
    <script type="text/javascript">
        $(function () {
           $('.chosen-container').css('width',"100%");
            var c_client = new OSS.Wrapper({
                region: 'oss-cn-shanghai',
                accessKeyId: 'LTAIqUbOPUz16zaX',
                accessKeySecret: 'FzQDTPRfbKRrJ3U9d6psiIa36iJ3lF',
                bucket: 'nuanguang-img'
            });
            $('#upload_img').bind('change', function (e) {
                var file = e.target.files[0];
                console.log(file);
                var ext=/.[^.]+$/.exec(file.name);
                var storeAs = 'img_lib/a'+new Date()*1 + parseInt(Math.random()*100)+ext;
                c_client.multipartUpload(storeAs, file).then(function (result) {
                    var html = template('upload-tpl', {src:result.url,name:storeAs});
                    $("#upload_list").append(html);
                }).catch(function (err) {
                    console.log(err);
                });
            });
        })
        function for_tag() {
            $("td.tag_list_js").each(function () {
                var td_id = $(this).attr('id');
                var data_ids = $(this).attr('data-ids');
                tag_list_echo(td_id, data_ids);
            });
        }
        function for_topic() {
            $("td.topic_list_js").each(function () {
                var td_id = $(this).attr('id');
                var data_ids = $(this).attr('data-ids');
                top_list_echo(td_id, data_ids);
            });
        }
        for_tag();
        for_topic();

        $(function () {
            $('.update_title').blur(function () {
                var id=$(this).attr('data-id');
                var data_title=$(this).attr('data-title');
                var title=$(this).val();
                var t=$(this);
                if(data_title == title){
                    return false;
                }
                $.ajax({
                    type:'post',
                    url:"index.php?c=post&m=up_title",
                    data:{'id':id,'title':title},
                    dataType:'json',
                    success:function(result){
                        if(result['status'] == 1){
                            // status.css({'color':'red'});
                            // console.log(t);
                            t.attr('data-title',title)
                            $("#desc_"+id+"").attr('rows',1);
                            add_scrolltop("desc_"+id+"",1)
                        }else{
                            alert("审核不通过失败")
                        }
                    }
                });
            });
        })


    </script>
<?php  include VIEWPATH.'common/footer.php';  ?>